#include "paper.h"
#include <QObject>
#include "person.h"
#include "iostream"
#include "sstream"
#include "vector"
using namespace std;
using std::ios;
using std::vector;
paper::paper(QObject *parent) : QObject(parent)
{

}
paper::paper(vector <QString> au,QString tit,QString id,QString ti,QString nm,int pg,bool s,bool e,bool i,bool c){
   auther=au;
   title=tit;
   ID=id;
   time=ti;
   name=nm;
   page=pg;
   sci=s;
   ei=e;
   istp=i;
   corn=c;}
QString paper::findid()
{
    return ID;
}
QString paper::findname()
{
    return name;
}

QString paper::findtitle(){                ///查询论文名称
return title;
}

QString paper::findtime(){              ///论文时间查询器
return time;
}
int paper::findpage(){                  ///论文页数查询器
return page;
}
bool paper::ifsci(){                   ///查询是否sci
return sci;
}
bool paper::ifei(){                      ///查询是否ei
return ei;
}
bool paper::ifistp(){                  ///查询是否为istp
return istp;
}
bool paper::ifcorn(){                ///查询是否为核心期刊
return corn;
}
bool paper::ifrelation(QString a,QString b){       ///查询两人是否有联系
    int m=0;
    for(unsigned int i=0;i<auther.size();i++){
        if(auther[i]==a){
            m+=1;
        }
        if(auther[i]==b){
            m+=1;
        }
        if(m==2){
            return 1;
        }
    }
    return 0;
}
void paper::save(ostringstream& os){
int r=0;
for(unsigned int i=0;i<auther.size();i++){
  if(r==0){
    os<<auther[i].toStdString();
    r=1;
  }
  else{
    os<<"，"<<auther[i].toStdString();
  }
}
os<<endl;
os<<title.toStdString()<<endl<<ID.toStdString()<<endl<<time.toStdString()<<endl<<name.toStdString()<<endl<<page<<endl<<sci<<endl<<ei<<endl<<istp<<endl<<corn<<endl;
}
bool paper::ifhave(QString mes)
{
    if(mes==title||mes==ID)
        return 1;
    else  return 0;
}
